//FileNameRenderer.java
import javax.swing.*;
import javax.swing.table.TableCellRenderer;
import java.util.Date;
import java.awt.*;
import java.io.File;

/*
 * This class makes a Path look like a File name in the JTable.
 */

public class FileNameRenderer implements TableCellRenderer {

   private JLabel alabel = new JLabel();

   public FileNameRenderer() {
      alabel.setOpaque(true);
   }

   public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected,
                                                  boolean hasFocus, int row, int column) {
      String S2 = "";
      String S1 = (String)value;
      DBFile f = new DBFile(S1);
      if(FileBrowserGUI.mode == "music"){
         if(f.getTitle() == null){
            f.setTitle();
            S2 = f.getTitle();
            }
         S2 = f.getTitle();

      }
      else{
         S2 = f.getName();
      }
      alabel.setText(S2);
      alabel.setFont(new Font("Arial", Font.BOLD, 16));
      alabel.setHorizontalAlignment(JLabel.LEFT);

      if (isSelected) {
         alabel.setBackground(table.getSelectionBackground());
      }
      else {
         alabel.setBackground(table.getBackground());
      }
      return alabel;
   }
}
